package action;

import core.Utility;
import data.Event;
import java.lang.String;

import parser.AddParser;

public class Default extends Find {

	private boolean specialFind;

	@Override
	public Event[] execute(String userCommand) {
		Event[] result = new Event[1];
		Event userEvent = AddParser.parseEvent(userCommand);
		specialFind = false;

		if(userEvent.getName() == null || userEvent.getName().equals("")) {
			specialFind = true;
			CheckIf newObj = new CheckIf();
			result = newObj.execute(userCommand);
		} else {
			result = super.execute("find " + userCommand);
		}
		return result;
	}

	@Override
	public Event[] undo() {
		return null;
	}

	@Override
	public boolean isUndoable() {
		return false;
	}

	@Override
	public String errorMessage() {
		if (specialFind) {
			return "Could not find free slot";
		} else {
			return super.errorMessage();
		}
	}
}
